<?php
/*
 * Camelot PHP Tools
 *
 * @version 2.0
 * @author Bendsoft
 * @package PHP Tools
 * @subpackage Camelot
 * @license FreeBSD License (www.bendsoft.com/licensing/)
 *
 */

/**
 * Object holding relevant data to form a document tree
 * 
 * @author Bendsoft
 */
class DocumentTreeObject {

    public $Id;
    public $ParentId;
    public $BaseName;
    public $ContentType;
    public $GUID;
    public $Modified;
    public $FileSize;
    public $FileType;
    public $LinkFilename;
    public $FolderPath;
    public $UrlPrefix;
    public $UrlSuffix;

    /**
     * @deprecated since version 2.0
     * @var string
     */
    public $Link;
    
    public function __construct($id, $parentId, $baseName, $contentType, $guid, $modified, $fileSize, $fileType, $linkFilename, $folderPath, $UrlPrefix = null, $UrlSuffix = null) {

        $this->Id = $id;
        $this->ParentId = $parentId;
        $this->BaseName = $baseName;
        $this->ContentType = $contentType;
        $this->GUID = $guid;
        $this->Modified = $modified;
        $this->FileSize = $fileSize;
        $this->FileType = $fileType;
        $this->LinkFilename = $linkFilename;
        $this->FolderPath = $folderPath;
        $this->UrlPrefix = $UrlPrefix;
        $this->UrlSuffix = $UrlSuffix;

        if ($contentType == "Folder") {
            $this->Link = "<a href='?parentId=$id'>$baseName</a><br />";
        } else {
            $this->Link = "<a href='?".$UrlPrefix."download=$folderPath$linkFilename$UrlSuffix'>$linkFilename</a>";
        }
    }
}
?>
